package com.cy.store.controller;

import com.cy.store.entity.Address;
import com.cy.store.entity.Product;
import com.cy.store.service.IAddressService;
import com.cy.store.service.IProductService;
import com.cy.store.util.JsonResults;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * 商品控制类
 */
@RestController //表示该控制类都以Json格式进行响应
//@Controller
@RequestMapping("product")
public class ProductController extends BaseController {
    @Autowired
    private IProductService productService;

    @RequestMapping("hot_list")
    public JsonResults<List<Product>> findHotList(){
        List<Product> data = productService.findHotList();
        return new JsonResults<>(OK,data);
    }

    @RequestMapping("{id}/details")
    public JsonResults<Product> getProductDetails(@PathVariable("id")  Integer id){
        Product data = productService.getProductDetails(id);
        return new JsonResults<>(OK,data);
    }

}
